import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
const originalPush = VueRouter.prototype.push;
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/regist',
		name: '注册',
		component: () => import( /* webpackChunkName: "about" */ '../views/Regist.vue')
	},
	{
		path: '/login',
		name: '登录',
		component: () => import( /* webpackChunkName: "about" */ '../views/Login.vue')
	},
	{
		path: '/write/:storeid/:parentid/:id?',
		name: '写文章',
		component: () => import( /* webpackChunkName: "about" */ '../views/Write.vue')
	},
	{
		path: '/index',
		component: Index,
		redirect: '/home',
		children: [{
				path: '/home',
				name: '首页',
				component: () => import( /* webpackChunkName: "about" */ '../views/Home.vue')
			},
			{
				path: '/article/:id',
				name: '查看文章',
				component: () => import( /* webpackChunkName: "about" */ '../views/articleview.vue')
			},
			{
				path: '/message',
				name: '消息',
				component: () => import( /* webpackChunkName: "about" */ '../views/message.vue')
			},
			{
				path: '/store/all',
				name: '知识库总览',
				component: () => import( /* webpackChunkName: "about" */ '../views/store.vue')
			},
			{
				path: '/store/:id',
				name: '知识库',
				component: () => import( /* webpackChunkName: "about" */ '../views/storeview.vue')
			},
			{
				path: '/userInfo/:id',
				name: '个人中心',
				component: () => import( /* webpackChunkName: "about" */ '../views/userinfo.vue')
			},
			{
				path: '/star',
				name: '收藏夹',
				component: () => import( /* webpackChunkName: "about" */ '../views/starArticle.vue')
			},
		]
	},

]

const router = new VueRouter({
	routes
})

export default router
